package com.example;

import com.example.config.AopConfig;
import com.example.service.OrderService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MainApp {
    public static void main(String[] args) {
        // 初始化Spring容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);
        
        // 获取OrderService实例
        OrderService orderService = context.getBean(OrderService.class);
        
        System.out.println("=== 测试add方法 ===");
        try {
            orderService.add("苹果", 5);
        } catch (Exception e) {
            System.out.println("捕获到异常: " + e.getMessage());
        }
        
        System.out.println("\n=== 测试delete方法 ===");
        try {
            orderService.delete("香蕉");
        } catch (Exception e) {
            System.out.println("捕获到异常: " + e.getMessage());
        }
        
        System.out.println("\n=== 测试find方法 ===");
        try {
            orderService.find("橙子");
        } catch (Exception e) {
            System.out.println("捕获到异常: " + e.getMessage());
        }
        
        // 关闭容器
        context.close();
    }
}
    